package org.zjsru.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@ResponseBody
@RequestMapping("/product")
public class TestController {
    @RequestMapping("/deduct")
    @SentinelResource(value = "test",blockHandler = "blockHandler",fallback = "fallback")
    public String test(){
//        System.out.println("劝君莫惜金缕衣，劝君惜少年时");
        return "deduct";
    }
    public String blockHandler(String s, BlockException e){
        return "限流了";
    }
    public String fallback(String s){
        return "降级了";
    }
}
